<%@ page import="com.the8thfold.anton.ant.JobStatus; org.apache.tools.ant.Target" contentType="text/html;charset=UTF-8" %>
<html>
<head>
    <title>View Job</title>
    <meta name="layout" content="main" />

</head>
<body>

<div>
    <h1>Job: ${job.name}</h1>
    <hr/>
    <h2>Choose targets to run</h2>
    <br/>
    <g:form name="targetSelectForm" controller="job" action="addTarget" id="${job.jobId}">
        <div class="css_right toolbar">
            <a class="btn-text" href="${createLink(controller: 'job', action: 'view', id: job.jobId)}">Cancel</a>
            <g:submitButton class="btn-text" name="submit" value="Add Targets"></g:submitButton>
        </div>
        <br/>
        <br/>
        <br/>
        <hr/>
        <br/>
        <table>
            <tr>
                <th></th>
                <th>Target Name</th>
                <th>Description</th>
                <th>Depends On</th>
                <th>If Condition</th>
                <th>Unless Condition</th>
                <th># Tasks</th>
            </tr>
            <g:each in="${targets}" status="targetsIndex" var="targetEntry">
                <g:if test="${!targetEntry.key?.isEmpty()}">
                    <tr class="${targetsIndex%2 ? 'odd' : 'even'}">
                        %{
                            Target value = targetEntry.value;
                            Enumeration deps = value.getDependencies();
                            String dependenciesString = "";
                            Iterator iter = deps.iterator();
                            while (iter.hasNext()) {
                                dependenciesString = dependenciesString + " " + iter.next();
                            }
                        }%
                        <td><input type="checkbox" name="jobtarget.${targetEntry.key}" /> </td>
                        <td style="${value.name.equalsIgnoreCase(antProject.getDefaultTarget()) ? 'font-weight: bold;' : ''}">${value.name}</td>
                        <td>${value.description}</td>
                        <td>${dependenciesString}</td>
                        <td>${value.if}</td>
                        <td>${value.unless}</td>
                        <td>${value.children?.size()}</td>
                    </tr>
                </g:if>
            </g:each>
        </table>
        <br/>
        <hr/>
        <br/>
        <div class="css_right toolbar">
            <a class="btn-text" href="${createLink(controller: 'job', action: 'view', id: job.jobId)}">Cancel</a>
            <g:submitButton class="btn-text" name="submit" value="Add Targets"></g:submitButton>
        </div>
    </g:form>
    <br/>

</div>
<br/>
<br/>
<br/>
</body>
</html>